|
|
|
|
|
|
|
CVar() converts any numeric or string expression into a variant value. Heres an example: |
|
|
|
 |
|
|
|
|
Private Sub cmdCVDate_Click()
Dim vntDate As Variant
Dim strDate As String
strDate = "4/1/95"
' This will create a string variant vntDate = CVDate(strDate)
Me.Cls
Me.Print "strDate = ""4/1/95"""
Me.Print "vntDate = CVDate(strDate) " & vntDate
Me.Print "VarType(vntDate) " & VarType(vntDate)
End Sub |
|
|
|
|
|
|
|
|
CDate() converts a string or string variant into a date type. Heres an example: |
|
|
|
 |
|
|
|
|
Private Sub cmdCVDate_Click ()
Dim dtDate As Date
Dim strDate As String
strDate = "4/1/95"
' This will create a string variant dtDate = CDate(strDate)
Me.Cls
Me.Print "strDate = ""4/1/95"""
Me.Print "dtDate = CVDate(strDate) " & dtDate
Me.Print "VarType(dtDate) " & VarType(dtDate)
End Sub |
|
|
|
|
|
|
|
|
You see the two sets of double quotes in the above code? The reason for this is you need to delimit strings in Visual Basic with double quotes, but if you need to get double quotes in your output on the screen, you will need to use two double quotes to get one in the final output. |
|
|
|
|
|